@use "sass:meta";

// Name:            Subnav
// Description:     Component to create a sub navigation
//
// Component:       `uk-subnav`
//
// Modifiers:       `uk-subnav-divider`
//                  `uk-subnav-pill`
//
// States:          `uk-active`
//                  `uk-first-column`
//
// ========================================================================


// Variables
// ========================================================================







/* ========================================================================
   Component: Subnav
 ========================================================================== */

/*
 * 1. Allow items to wrap into the next line
 * 2. Center items vertically if they have a different height
 * 3. Gutter
 * 4. Reset list
 */

.uk-subnav {
    display: flex;
    /* 1 */
    flex-wrap: wrap;
    /* 2 */
    align-items: center;
    /* 3 */
    margin-left: (-$subnav-margin-horizontal);
    /* 4 */
    padding: 0;
    list-style: none;
    @if(meta.mixin-exists(hook-subnav)) {@include hook-subnav();}
}

/*
 * 1. Space is allocated solely based on content dimensions: 0 0 auto
 * 2. Gutter
 * 3. Create position context for dropdowns
 */

.uk-subnav > * {
    /* 1 */
    flex: none;
    /* 2 */
    padding-left: $subnav-margin-horizontal;
    /* 3 */
    position: relative;
}


/* Items
 ========================================================================== */

/*
 * Items must target `a` elements to exclude other elements (e.g. dropdowns)
 * Using `:first-child` instead of `a` to support `span` elements for text
 * 1. Center content vertically, e.g. an icon
 * 2. Imitate white space gap when using flexbox
 * 3. Style
 */

.uk-subnav > * > :first-child {
    /* 1 */
    display: flex;
    align-items: center;
    /* 2 */
    column-gap: 0.25em;
    /* 3 */
    color: $subnav-item-color;
    @if(meta.mixin-exists(hook-subnav-item)) {@include hook-subnav-item();}
}

/* Hover */
.uk-subnav > * > a:hover {
    color: $subnav-item-hover-color;
    text-decoration: $subnav-item-hover-text-decoration;
    @if(meta.mixin-exists(hook-subnav-item-hover)) {@include hook-subnav-item-hover();}
}

/* Active */
.uk-subnav > .uk-active > a {
    color: $subnav-item-active-color;
    @if(meta.mixin-exists(hook-subnav-item-active)) {@include hook-subnav-item-active();}
}


/* Divider modifier
 ========================================================================== */

/*
 * Set gutter
 */

.uk-subnav-divider { margin-left: -(($subnav-divider-margin-horizontal * 2) + $subnav-divider-border-width); }

/*
 * Align items and divider vertically
 */

.uk-subnav-divider > * {
    display: flex;
    align-items: center;
}

/*
 * Divider
 * 1. `nth-child` makes it also work without JS if it's only one row
 */

.uk-subnav-divider > ::before {
    content: "";
    height: $subnav-divider-border-height;
    margin-left: ($subnav-divider-margin-horizontal - $subnav-margin-horizontal);
    margin-right: $subnav-divider-margin-horizontal;
    border-left: $subnav-divider-border-width solid transparent;
}

/* 1 */
.uk-subnav-divider > :nth-child(n+2):not(.uk-first-column)::before {
    border-left-color: $subnav-divider-border;
    @if(meta.mixin-exists(hook-subnav-divider)) {@include hook-subnav-divider();}
}


/* Pill modifier
 ========================================================================== */

/*
 * Gutter
 */

.uk-subnav-pill { margin-left: (-$subnav-pill-margin-horizontal); }
.uk-subnav-pill > * { padding-left: $subnav-pill-margin-horizontal; }

.uk-subnav-pill > * > :first-child {
    padding: $subnav-pill-item-padding-vertical $subnav-pill-item-padding-horizontal;
    background: $subnav-pill-item-background;
    color: $subnav-pill-item-color;
    @if(meta.mixin-exists(hook-subnav-pill-item)) {@include hook-subnav-pill-item();}
}

/* Hover */
.uk-subnav-pill > * > a:hover {
    background-color: $subnav-pill-item-hover-background;
    color: $subnav-pill-item-hover-color;
    @if(meta.mixin-exists(hook-subnav-pill-item-hover)) {@include hook-subnav-pill-item-hover();}
}

/* OnClick */
.uk-subnav-pill > * > a:active {
    background-color: $subnav-pill-item-onclick-background;
    color: $subnav-pill-item-onclick-color;
    @if(meta.mixin-exists(hook-subnav-pill-item-onclick)) {@include hook-subnav-pill-item-onclick();}
}

/* Active */
.uk-subnav-pill > .uk-active > a {
    background-color: $subnav-pill-item-active-background;
    color: $subnav-pill-item-active-color;
    @if(meta.mixin-exists(hook-subnav-pill-item-active)) {@include hook-subnav-pill-item-active();}
}


/* Disabled
 * The same for all style modifiers
 ========================================================================== */

.uk-subnav > .uk-disabled > :first-child {
    color: $subnav-item-disabled-color;
    @if(meta.mixin-exists(hook-subnav-item-disabled)) {@include hook-subnav-item-disabled();}
}


// Hooks
// ========================================================================

@if(meta.mixin-exists(hook-subnav-misc)) {@include hook-subnav-misc();}

// @mixin hook-subnav(){}
// @mixin hook-subnav-item(){}
// @mixin hook-subnav-item-hover(){}
// @mixin hook-subnav-item-active(){}
// @mixin hook-subnav-divider(){}
// @mixin hook-subnav-pill-item(){}
// @mixin hook-subnav-pill-item-hover(){}
// @mixin hook-subnav-pill-item-onclick(){}
// @mixin hook-subnav-pill-item-active(){}
// @mixin hook-subnav-item-disabled(){}
// @mixin hook-subnav-misc(){}


// Inverse
// ========================================================================




// @mixin hook-inverse-subnav-item(){}
// @mixin hook-inverse-subnav-item-hover(){}
// @mixin hook-inverse-subnav-item-active(){}
// @mixin hook-inverse-subnav-divider(){}
// @mixin hook-inverse-subnav-pill-item(){}
// @mixin hook-inverse-subnav-pill-item-hover(){}
// @mixin hook-inverse-subnav-pill-item-onclick(){}
// @mixin hook-inverse-subnav-pill-item-active(){}
// @mixin hook-inverse-subnav-item-disabled(){}
